<?php
/* 
 * ebiz front
 * 
 * TagUtil
 * 
 * @author allen
 * 
 */

require_once '../app/constants/ConfigConstants.php';
class TagUtil
{   
	
	public static function renderLabel($id ,$defaultAttr = array(), $attr = array()){
		$attrStr = "";
		$label = isset($defaultAttr['label']) ? $defaultAttr['label'] : "";
		foreach($defaultAttr as $key => $default){
			if($key != "label"){ 	//do not have label value, have other default value or attribute value
				if(isset($attr[$key]) && $attr[$key] != ""){ 	//have other attribute of scp file
					$attrStr .= " " . "$key='" . "$attr[$key]"."' " ;		//add other attribute
				}else{ 	//have other attribute of defaultAttr value
					$attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ; 	//get the defaultAttr value
				}
			}else{ 	//have default label value
//				$label = $attr[$key] == "" ? $defaultAttr['label'] : $attr[$key]; 	//compare with scp file value
//				$label = isset($attr[$key]) && $attr[$key] != "" ? $attr[$key] : $defaultAttr[$key]; 	
				$label = isset($attr[$key]) ? $attr[$key] : $defaultAttr[$key]; 	//0622 new add
			}
		}
		return " \n <label id='$id' $attrStr > \n ".$label." \n </label> \n ";
	}
	
	public static function renderInput($id, $defaultAttr = array(), $attr = array()){
		$attrStr = "";
		foreach($defaultAttr as $key => $default){
			if($key != "size"){
				if(isset($attr[$key]) && $attr[$key] != ""){ 	
					$attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
				}else{ 	
					$attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
				}
			}else{ 
				if($defaultAttr['size'] == "" && !isset($attr['size'])){
					$attrStr .= "";
				}else if($defaultAttr[$key] != "" && !isset($attr[$key])){ //0622 modify
					$attrStr .= " size='".$defaultAttr['size']."' ";
				}else{  //defaultAttr and attr all equal null or defaultAttr equal null
					$attrStr .= " size='".$attr['size']."' ";
				}
			}
		}
		return " \n <input $attrStr id='$id' /> \n ";
	}
	
	public static function renderButton($id, $defaultAttr = array(), $attr = array()){
		$attrStr = "";
//        $size = isset($defaultAttr['value']) ? $defaultAttr['value'] : "";
        foreach($defaultAttr as $key => $default){
            if($key != "value"){
                if(isset($attr[$key]) && $attr[$key] != ""){    
                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
                }else{  
                    $attrStr .= $defaultAttr == "" ? "" : " " . "$key='" . "$default"."' " ;
                }
            }else{ 
                if($defaultAttr[$key] == "" && !isset($attr[$key])){
                    $attrStr .= "";
                }else if($defaultAttr[$key] != "" && !isset($attr[$key])){ 
                    $attrStr .= " value='".$defaultAttr['value']."' ";
                }else{  
                    $attrStr .= " value='".$attr[$key]."' ";
                } 
            }
        }
        return " \n <input id='$id' $attrStr /> \n ";
	}

	public static function renderButtonOrImage($id, $defaultButton = array(), $defaultImage = array(), $attr = array()){
		if($attr["type"] == "button"){
			return self::renderButton($id, $defaultButton, $attr);
//		}else if($attr["type"] == "submit"){
//			return self::renderSubmit($id, $defaultButton, $attr);
		}else{
			$defaultAttr = $defaultImage;
	        $config = $GLOBALS["config"];   //the value in the init file
	        $attrStr = "";
	        if(!isset($attr['src'])){
	            return '';
	        }
	        foreach($defaultAttr as $key => $default){
	            if($key != "src" && $key != "alt"){
	                if(isset($attr[$key]) && $attr[$key] != ""){    
	                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
	                }else{  
	                    $attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
	                }
	            }elseif($key == "src"){ 
	                if($defaultAttr['src'] != "" && !isset($attr['src'])){ 
	                    $attrStr .= " src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$defaultAttr['src']."' ";    
	                }else{  
	                    $attrStr .= " src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$attr['src']."'  ";
	                }
	            }else if($key == "alt"){ 
	                if($defaultAttr[$key] != "" && !isset($attr[$key])){
	                    $attrStr .= " alt='".$defaultAttr['alt']."' ";
	                }else{  
	                    $attrStr .= " alt='".$attr[$key]."' ";
	                }
	            }
	        }
	        if(empty($id)){
	            $html = "<input $attrStr />";
	        }else{
	            $html = "<input $attrStr id='$id' />";
	        }
	        return " \n $html \n ";
			
			
//			$attrStr = "";
//			foreach($defaultImage as $key => $default){
////				if(isset($attr[$key]) && $attr[$key] != ""){
//				if(isset($attr[$key])){ //0622 add
//					$attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
//				}else{
//					$attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
//				}
//			}
//			return " \n <input id='$id' ".$attrStr." /> \n ";
		}
	}

	public static function renderJSCode($name = ""){
		if(!empty($name)){
			return " \n <script type='text/javascript' language='javascript' src='".$name."' ></script> \n ";
		}else{
			return "";
		}
	}
	
	public static function renderCSSCode($name = ""){
		if(!empty($name)){
			return " \n <link rel='stylesheet' type='text/css' href='".$name."' /> \n ";
		}else{
			return "";
		}
	}
	
    public static function renderLink($defaultAttr = array(), $attr = array()){
        $attrStr = "";
        $label = isset($defaultAttr['label']) ? $defaultAttr['label'] : "";
        foreach($defaultAttr as $key => $default){
            if($key != "label"){    //do not have label value, have other default value or attribute value
                if(isset($attr[$key]) && $attr[$key] != ""){    //have other attribute of scp file
                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;       //add other attribute
                }else{  //have other attribute of defaultAttr value
                    $attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;    //get the defaultAttr value
                }
            }else{  //have default label value
//                $label = isset($attr[$key]) && $attr[$key] != "" ? $attr[$key] : $defaultAttr[$key];   //compare with scp file value
                $label = isset($attr[$key]) ? $attr[$key] : $defaultAttr[$key];   //compare with scp file value
            }
        }
        return " \n <a $attrStr > \n ".$label." \n </a> \n ";
    }
    
    /**
     * this src path in private image path , use 8082 port
     */
//    public static function renderLogoImage($defaultAttr = array(), $attr = array(), $sslProtocol = "http"){  
    public static function renderLogoImage($defaultAttr = array(), $attr = array()){  
    	$config = $GLOBALS["config"];   //the value in the init file
        $attrStr = "";
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";   
            //$attr[$key] = isset($attr[$key]) ? $attr[$key] : "";  
        	if($key != "src" && $key != "alt"){     
                if(isset($attr[$key]) && $attr[$key] != ""){    
                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
                }else{  
                    $attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
                }
            }else if($key == "src"){ 
                if($defaultAttr[$key] == "" && $attr[$key] == ""){
                    $attrStr .= "";
                }else if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $attrStr .= " src='//".ConfigConstants::$piConstants.".".DOMAIN."/".$defaultAttr['src']."' ";
                }else{  //defaultAttr and attr all equal null or defaultAttr equal null
                    $attrStr .= " src='//".ConfigConstants::$piConstants.".".DOMAIN."/".$attr[$key]."'  ";
                }
            }else if($key == "alt"){ 
//                if($defaultAttr[$key] == "" && $attr[$key] == ""){
                if($defaultAttr[$key] == "" && !isset($attr[$key])){ //0622 Modify
                    $attrStr .= "";
//                }else if($defaultAttr[$key] != "" && $attr[$key] == ""){
                }else if($defaultAttr[$key] != "" && !isset($attr[$key])){ //0622 Modify
                    $defaultAttr[$key] = self::renderTemplateParam($defaultAttr[$key]);    //0622 new add
                    $attrStr .= " alt='".$defaultAttr['alt']."' ";
                }else{  //defaultAttr and attr all equal null or defaultAttr equal null
                	$attr[$key] = self::renderTemplateParam($attr[$key]);
                	$attrStr .= " alt='".$attr[$key]."' ";
                }
            }
        }
        return " \n <img $attrStr /> \n ";
    }
    
//    public static function renderImage($defaultAttr = array(), $attr = array(), $sslProtocol = "http"){
    public static function renderImage($defaultAttr = array(), $attr = array()){
    	$config = $GLOBALS["config"];   //the value in the init file
        $attrStr = "";
        if(!isset($attr['src'])){
        	return '';
        }
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";   //===========
//            $attr[$key] = isset($attr[$key]) ? $attr[$key] : "";  //==================new add at 0423
        	if($key != "src" && $key != "alt"){     //i add 0415
                if(isset($attr[$key]) && $attr[$key] != ""){    
                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
                }else{  
                    $attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
                }
            }else if($key == "src"){ 
                if($defaultAttr[$key] == "" && $attr[$key] == ""){
                    $attrStr .= "";
                }else if($defaultAttr[$key] != "" && $attr[$key] == ""){
                    $attrStr .= " src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$defaultAttr[$key]."' ";
                }else{  //defaultAttr and attr all equal null or defaultAttr equal null
                    $attrStr .= " src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$attr[$key]."'  ";
                }
            }else if($key == "alt"){ 
//                if($defaultAttr[$key] == "" && $attr[$key] == ""){
                if($defaultAttr[$key] == "" && !isset($attr[$key])){
                    $attrStr .= "";
//                }else if($defaultAttr[$key] != "" && $attr[$key] == ""){
                }else if($defaultAttr[$key] != "" && !isset($attr[$key])){
                	$defaultAttr[$key] = self::renderTemplateParam($defaultAttr[$key]);    //0622 new add
                	$attrStr .= " alt='".$defaultAttr['alt']."' ";
                }else{  //defaultAttr and attr all equal null or defaultAttr equal null
                	$attr[$key] = self::renderTemplateParam($attr[$key]);
                	$attrStr .= " alt='".$attr[$key]."' ";
                }
            }
        }
        return " \n <img $attrStr /> \n ";
    }
    
    private function renderTemplateParam($param){
        $config = $GLOBALS["config"];
        $domain = $config ['domain'];
        $siteName = $config ['site_name'];
        $str = str_replace("{%SITE_NAME%}", $siteName, $param);
        $str = str_replace("{%DOMAIN%}", $domain, $str);
        return $str;
    }
    
    
//    public static function renderLoginForm($defaultAttr = array(), $attr = array(), $sslProtocol = "http"){
    public static function renderLoginForm($defaultAttr = array(), $attr = array()){
        $path = "../$GLOBALS[local]/"."header.php";     
        require_once $path;
        $config = $GLOBALS["config"];
        if(!isset($attr['login_image_src'])){
            return '';
        }
        $html = " \n <div id='iHeaderLoginForm'>";
        $html .= " \n <form method='post' action='/o/login'>";
        $imgAlt = "";
        $imgSrc = "";
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";   
//            $attr[$key] = isset($attr[$key]) ? $attr[$key] : "";  
            if($key == "email_label"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <label id='loginFormEmailLabel'>".$default."</label>";
                }else{
                    $html .= " \n <label id='loginFormEmailLabel'>".$attr[$key]."</label>";
                }
            }else if($key == "email_textbox_size"){ 
                if($defaultAttr[$key] == "" && !isset($attr[$key])){
                    $html .= " \n <input id='loginFormEmailBox' type='text' name='emaill'  />";
                }elseif($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <input id='loginFormEmailBox' type='text' size='".$default."' name='emaill'  />";
                }else{
                    $html .= " \n <input id='loginFormEmailBox' type='text' size='".$attr[$key]."' name='emaill'  />";
                }
            }else if($key == "password_label"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <label id='loginFormPasswordLabel'>".$default."</label>";
                }else{
                    $html .= " \n <label id='loginFormPasswordLabel'>".$attr[$key]."</label>";
                }
            }else if($key == "password_textbox_size"){ 
                if($defaultAttr[$key] == "" && !isset($attr[$key])){
                    $html .= " \n <input id='headerEmailBox' type='password' name='passwordl'  />";
                }elseif($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <input id='loginFormPasswordBox' type='password' size='".$default."' name='passwordl'  />";
                }else{
                    $html .= " \n <input id='loginFormPasswordBox' type='password' size='".$attr[$key]."' name='passwordl'  />";
                }
            }else{ 
                if($key == "login_image_src"){ 
                    if($defaultAttr[$key] != "" && !isset($attr[$key])){
                        $imgSrc = $defaultAttr[$key];
                    }else{
                        $imgSrc = $attr[$key];
                    }
                }else if($key == "login_image_alt"){ 
                    if($defaultAttr[$key] != "" && !isset($attr[$key])){
                        $imgAlt = $defaultAttr[$key];
                    }else{
                        $imgAlt = $attr[$key];
                    }
                }
            }
        }
        $html .= " \n <input type='image' id='loginFormButton' alt='".$imgAlt."' src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$imgSrc."' />";
        $html .= " \n </form>";     
        $html .= " \n </div> \n ";      
        return $html;
    }
    
//    public static function renderSearchForm($defaultAttr = array(), $attr = array(), $sslProtocol = "http"){
    public static function renderSearchForm($defaultAttr = array(), $attr = array()){
        $path = "../$GLOBALS[local]/"."header.php";     
        require_once $path;
        $config = $GLOBALS["config"];
        if(!isset($attr['search_image_src'])){
        	return '';
        }
        $html = "";
        $html .= " \n <div id='iHeaderSearch'>";
        $html .= " \n <form action='/u/search' method='post'>";
        $imgAlt = "";
        $imgSrc = "";
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";   
            if($key == "search_label"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                	$html .= " \n <label id='headerSearchLabel'>".$default."</label>"; 
                }else{
                    $html .= " \n <label id='headerSearchLabel'>".$attr[$key]."</label>"; 
                }
            }else if($key == "search_textbox_size"){ 
                if($defaultAttr[$key] == "" && !isset($attr[$key])){
                    $html .= " \n <input type='text' id='headerSearchBox' name='headerSearch'/>";
                }elseif($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <input size='$default'  type='text' id='headerSearchBox' name='headerSearch'/>";
                }else{
                    $html .= " \n <input size='$attr[$key]'  type='text' id='headerSearchBox' name='headerSearch'/>";
                }
            }else{ 
	            if($key == "search_image_src"){ 
	                if($defaultAttr[$key] != "" && !isset($attr[$key])){
	                	$imgSrc = $defaultAttr[$key];
	                }else{
	                	$imgSrc = $attr[$key];
	                }
	            }else if($key == "search_image_alt"){ 
	                if($defaultAttr[$key] != "" && !isset($attr[$key])){
	                    $imgAlt = $defaultAttr[$key];
	                }else{
	                    $imgAlt = $attr[$key];
	                }
	            }
            }
        }
        $html .= " \n <input type='image' id='headerSearchButton' alt='".$imgAlt."' src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$imgSrc."' />";
        $html .= " \n </form>";
        $html .= " \n </div> \n ";
        return $html;
    }

//    public static function renderInputImage($id, $defaultAttr = array(), $attr = array(), $sslProtocol = "http"){
    public static function renderInputImage($id, $defaultAttr = array(), $attr = array()){
        $config = $GLOBALS["config"];   //the value in the init file
        $attrStr = "";
        if(!isset($attr['src'])){
            return '';
        }
        foreach($defaultAttr as $key => $default){
            if($key != "src" && $key != "alt"){
                if(isset($attr[$key]) && $attr[$key] != ""){    
                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
                }else{  
                    $attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
                }
            }elseif($key == "src"){ 
                if($defaultAttr['src'] != "" && !isset($attr['src'])){ 
                    $attrStr .= " src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$defaultAttr['src']."' ";    
                }else{  
                    $attrStr .= " src='//".ConfigConstants::$iConstants.".".DOMAIN."/t/".$config['template_name']."/image/".$attr['src']."'  ";
                }
            }else if($key == "alt"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
//                    $defaultAttr[$key] = self::renderTemplateParam($defaultAttr[$key]);    
                    $attrStr .= " alt='".$defaultAttr['alt']."' ";
                }else{  
//                    $attr[$key] = self::renderTemplateParam($attr[$key]);
                    $attrStr .= " alt='".$attr[$key]."' ";
                }
            }
        }
        if(empty($id)){
        	$html = "<input $attrStr />";
        }else{
        	$html = "<input $attrStr id='$id' />";
        }
        return " \n $html \n ";
    }
    
    /**
     * generate the quantity label and select 
     */
    public static function renderQuantityInfo($defaultAttr = array(), $attr = array(), $defaultItemId, $productItemInfo){  
        $html = "";
    	foreach ($productItemInfo as $key => $item) {
            if(substr($key, 0, 4) == 'item'){
                $itemId = $item['id'];
                if($defaultItemId == $itemId){
                    $quantity = $item['inventory']; 
                    if(empty($quantity)){
                        $html = self::renderHideQuantityHtml($defaultAttr, $attr);
                    }else{
                    	$html = self::renderShowQuantityHtml($defaultAttr, $attr);
                    }
                }
            }
        }
        return $html;
    }
    
    /**
     * generate the quantity label and select html code//set the label and select is show
     */
    private static function renderShowQuantityHtml($defaultAttr = array(), $attr = array()){  
        $html = "";
    	$html .= " \n <div id='productQuantity'> \n ";
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";   
            if($key == "label"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <label id='productQuantityLabel'> \n ".$default." \n </label> \n "; 
                }else{
                    $html .= " \n <label id='productQuantityLabel'> \n ".$attr[$key]." \n </label> \n "; 
                }
            }else if($key == "max"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                	$html .= self::renderDefaultQuantitySelect($default);
//                    $html .= "<select id='productQuantitySelect' name='quantity'>";
//                    for($i = 1; $i <= $default; $i++){
//                        $html .= "<option value=".$i.">".$i."</option>";
//                    }
//                    $html .= "</select>";
                }else{
                    if(is_numeric($attr[$key])){
                        $qty = $attr[$key] + 0;
                        if(is_int($qty)){
                            if($qty > 0){
                                $html .= " \n <select id='productQuantitySelect' name='quantity'>";
                                for($i = 1; $i <= $qty; $i++){
                                    $html .= " \n <option value='".$i."'>".$i."</option>";
                                }
                                $html .= " \n </select> \n ";
                            }else{
                            	$html .= self::renderDefaultQuantitySelect($default);
                            }
                        }else{
                        	$html .= self::renderDefaultQuantitySelect($default);
                        }
                    }else{
                    	$html .= self::renderDefaultQuantitySelect($default);
                    }
                }
            }
        }
        $html .= "</div>";
        return $html;
    }
    
    /**
     * generate the quantity label and select html code//set the label and select is hide
     */
    private static function renderHideQuantityHtml($defaultAttr = array(), $attr = array()){  
        $html = "";
    	$html .= " \n <div id='productQuantity'>";
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";   
            if($key == "label"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <label id='productQuantityLabel' style='display: none;'>".$default."</label>"; 
                }else{
                    $html .= " \n <label id='productQuantityLabel' style='display: none;'>".$attr[$key]."</label>"; 
                }
            }else if($key == "max"){ 
                if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $html .= " \n <select id='productQuantitySelect' name='quantity' style='display: none;'>";
                    for($i = 1; $i <= $default; $i++){
                        $html .= " \n <option value='".$i."'>".$i."</option>";
                    }
                    $html .= " \n </select> \n ";
                }else{
                    if(is_numeric($attr[$key])){
                        $qty = $attr[$key] + 0;
                        if(is_int($qty)){
                            if($qty > 0){
                                $html .= " \n <select id='productQuantitySelect' name='quantity' style='display: none;'>";
                                for($i = 1; $i <= $qty; $i++){
                                    $html .= " \n <option value='".$i."'>".$i."</option>";
                                }
                                $html .= " \n </select> \n ";
                            }
                        }
                    }
                }
            }
        }
        $html .= "</div>";
        return $html;
    }
    
    /**
     * generate the quantity select html
     */
    private function renderDefaultQuantitySelect($default){
        $html = "";
    	$html .= " \n <select id='productQuantitySelect' name='quantity'>";
        for($i = 1; $i <= $default; $i++){
            $html .= " \n <option value='".$i."'>".$i."</option>";
        }
        $html .= " \n </select> \n ";
        return $html;
    }
    
    /**
     * generate product item image from private path
     */
    /*
    public static function renderItemImage($defaultAttr = array(), $attr = array(), $sslProtocol = "http"){
        $attrStr = "";
        $attr['src'] = isset($attr['src']) ? $attr['src'] : ""; 
        $attr['alt'] = isset($attr['alt']) ? $attr['alt'] : ""; 
        foreach($defaultAttr as $key => $default){
            $defaultAttr[$key] = isset($defaultAttr[$key]) ? $defaultAttr[$key] : "";  
            if($key != "src" && $key != "alt"){     
                if(isset($attr[$key]) && $attr[$key] != ""){    
                    $attrStr .= " " . "$key='" . "$attr[$key]"."' " ;
                }else{  
                    $attrStr .= $default == "" ? "" : " " . "$key='" . "$default"."' " ;
                }
            }else if($key == "src"){ 
                if($defaultAttr[$key] == "" && $attr[$key] == ""){
                    $attrStr .= "";
                }else if($defaultAttr[$key] != "" && $attr[$key] == ""){
                    $attrStr .= " src='".$sslProtocol."://".PRIVATEIMAGEROOT."/p".$defaultAttr[$key]."' ";
                }else{  //defaultAttr and attr all equal null or defaultAttr equal null
                    $attrStr .= " src='".$sslProtocol."://".PRIVATEIMAGEROOT."/p".$attr[$key]."'  ";
                }
            }else if($key == "alt"){ 
                if($defaultAttr[$key] == "" && !isset($attr[$key])){
                    $attrStr .= "";
                }else if($defaultAttr[$key] != "" && !isset($attr[$key])){
                    $defaultAttr[$key] = self::renderTemplateParam($defaultAttr[$key]);    //0622 new add
                    $attrStr .= " alt='".$defaultAttr['alt']."' ";
                }else{  //defaultAttr and attr all equal null or defaultAttr equal null
                    $attr[$key] = self::renderTemplateParam($attr[$key]);
                    $attrStr .= " alt='".$attr[$key]."' ";
                }
            }
        }
        return " \n <img $attrStr /> \n ";
    }
    */
}



